import { defineConfig, ConfigEnv } from "vite";
import vue from "@vitejs/plugin-vue";

// https://vitejs.dev/config/
export default defineConfig((mode: ConfigEnv) => {
  return {
    base: mode.command === "serve" ? "./" : "/dist/",
    server: {
      host: "0.0.0.0",
      proxy: {
        "/api": {
          target: "https://api.weixin.qq.com",
          changeOrigin: true,
          rewrite: (path) => path.replace(/^\/api/, ""),
        },
        "/server": {
          target: "http://localhost:3000/",
          changeOrigin: true,
          rewrite: (path) => path.replace(/^\/server/, ""),
        },
      },
    },
    plugins: [vue()],
  };
});
